package MovieFinderApp;

import java.util.Map;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import MovieFinderApp.MCMOvieOutputInterfaces.IMovieOutput;
import MovieFinderApp.MCMovieFinderInterfaces.IMovieFinder;
import MovieFinderApp.MCMovieListerInterfaces.IMovieLister;
import MovieFinderApp.MCGUIInterfaces.IGUI;

public class MovieFinderApp {

    public static void main(String[] args) {
        
        ApplicationContext appCon = new FileSystemXmlApplicationContext("classpath:MovieFinderApp/properties/config.xml");
        IMovieLister movieLister = (IMovieLister)appCon.getBean("myMovieLister");
        IMovieOutput movieOutput = (IMovieOutput)appCon.getBean("myMovieOutput");
        IGUI theGUI = (IGUI)appCon.getBean("myGUI");
        
        Map<String, IMovieFinder> allMovieFinders = (Map<String, IMovieFinder>)appCon.getBeansOfType(IMovieFinder.class);
        theGUI.setMovieFinders(allMovieFinders);
        theGUI.setMovieLister(movieLister);

        movieLister.addPropertyChangeListener(movieOutput);
        movieLister.addPropertyChangeListener(theGUI);
    }
}
